Next | Prev | Up | Top | Contents | Index

Mapping a VME Device Into Process Address Space

As discussed in "Device Addresses", an I/O device is represented as an address, or range of addresses, in the physical address space. A kernel-level device driver has the ability to set up a mapping between the address of a device register and an arbitrary location in the address space of a user-level process. When this has been done, the device register appears to be a variable in memory. The program can assign values to it, or refer to it in expressions.


Learning VME Device Addresses

In order to map a VME device for PIO, you must know the following points:

This information is normally supplied by the manufacturer of a third-party VME device. You can find these values for Silicon Graphics equipment by examining the /var/sysgen/system/irix.sm file, in which each configured VME device is specified by a VECTOR line. When you examine a VECTOR line, note the following parameter values:

bustypeSpecified as VME for VME devices. The VECTOR statement can be used for other types of buses as well.
adapter The number of the VME bus where the device is attached.
iospace, iospace2, iospace3 Each iospace group specifies the VME address space and modifier, the starting bus address, and the size of a segment of VME address space used by this device.

Within each iospace parameter group you find keywords and numbers for the address space, modifier, and addresses for a device. The following is an example of a VECTOR line:

VECTOR: bustype=VME module=cdsio ipl=5 ctlr=0 adapter=0 iospace=(A24S,0xF00000,0x10000) probe_space=(A24S,0xF0FFFF,1)

This example specifies a VME device (bustype=VME) on bus 0 (adapter=0). The device resides in the A24 address space in supervisory mode (iospace=(A24S...)). Its first VME bus address is 0xF0 0000 and it covers a span of 0x01 0000 (64K) addresses--in other words, 0xF0 0000 through 0xF0 FFFF.

For third-party VME devices, look for a VECTOR line supplied by the manufacturer, usually stored in some file in /var/sysgen/system.


Opening a Device Special File

When you know the device addresses, you can open a device special file that represents the correct range of addresses. The device special files for VME mapping are found in /dev/vme.

The naming convention for these files is documented in the usrvme(7) reference page. Briefly, each file is named vmeBaSM, where

B is one or two digits for the bus number, for example 0 or 53
S is two digits for the address space, 16, 24, or 32
M is the modifier, either s for supervisory or n for nonprivileged

The device special file for the device described by the example VECTOR line in the preceding section would be /dev/vme/vme0a24s.

In order to map a device on a particular bus and address space, you must open the corresponding file in /dev/vme.


Using the mmap() Function

When you have successfully opened the device special file, you use the file descriptor as the primary input parameter in a call to the mmap() system function.

This function is documented for all its many uses in the mmap(2) reference page. For purposes of mapping a VME device into memory, the parameters should be as follows (using the names from the reference page):

addr Should be NULL to permit the kernel to choose an address in user process space.
len The length of the span of VME addresses, as documented in the iospace group in the VECTOR line.
prot PROT_READ for input, PROT_WRITE for output, or the logical sum of those names when the device will be used for both input and output.
flags MAP_SHARED, with the addition of MAP_PRIVATE if this mapping is not to be visible to child processes created with the sproc() function (see the sproc(2) reference page).
fd The file descriptor returned from opening the device special file in /dev/vme.
off The starting VME bus address, as documented in the iospace group in the VECTOR line.

The value returned by mmap() is the virtual address that corresponds to the starting VME bus address. When the process accesses that address, the access is implemented by data transfer to the VME bus.


Map Size Limits

There are limits to the amount and location of VME bus address space that can be mapped for PIO. The system architecture can restrict the span of mappable addresses, and kernel resource constraints can impose limits.

In all systems that support the VME bus it is possible to map all of A16 space.

In a Silicon Graphics Crimson system, the upper 8 MB of A24 space, from 0x80 0000 to 0xFF FFFF can be mapped. Only a fixed part of the A32 space can be mapped. A total of 256 MB of addresses is divided between the supervisor and nonprivileged A32 spaces on one or two VME buses. For details of the VME bus addresses, see "Crimson Mapping of A32 Space". VME devices that respond to addresses in the ranges shown in that section can be mapped for PIO.

In the Silicon Graphics Challenge and Onyx systems, all of A24 and A32 space can be used for PIO mappings, but there is a limit on the size of each map. Each bus mapping uses a hardware register that can span as much as 8 MB of contiguous VME bus addresses--so a single mmap() call can map at most 8 MB. There are as many as 12 mapping registers for each bus, so by making successive mmap() calls for adjacent 8 MB blocks of VME space you can map up to 96 MB of VME space into user process space from a single bus.


Next | Prev | Up | Top | Contents | Index